package org.example.socket;

import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.handler.stream.StreamIoHandler;
import org.apache.log4j.Logger;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;

public class ServerSocketHandler extends StreamIoHandler {
    private static Logger logger = new Logger(ServerSocketHandler.class.getName()) {
    };
    @Override
    protected void processStreamIo(IoSession ioSession, InputStream inputStream, OutputStream outputStream) {

    }
    @Override
    public void messageReceived(IoSession session, Object message) {
        logger.debug(message.toString() + ":" + new Date());
    }
    @Override
    public void exceptionCaught(IoSession session, Throwable cause){
        logger.error("MINA发生异常：", cause);
    }
    @Override
    public void sessionOpened(IoSession session) {
        super.sessionOpened(session);
    }
    @Override
    public void sessionIdle(IoSession session, IdleStatus status){
        super.sessionIdle(session, status);
    }
}
